local sk__guiqu = fk.CreateSkill {

  name = "sk__guiqu",

  tags = { Skill.Compulsory, },

}



sk__guiqu:addEffect("viewas", {
  name = "sk__guiqu",
  anim_type = "support",
  frequency = Skill.Compulsory, --已经不想吐槽锁定转化技了
  pattern = "peach",
  prompt = "#sk__guiqu",
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    local card = Fk:cloneCard("peach")
    card.skillName = sk__guiqu.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local skills = {}
    for _, s in ipairs(player.player_skills) do
      if s:isPlayerSkill(player) and s.visible then
        table.insert(skills, s.name)
      end
    end
    local result = room:askForCustomDialog(player, sk__guiqu.name,
      "packages/utility/qml/ChooseSkillBox.qml", {
        skills, 1, 1, "#sk__guiqu-choice"
      })
    local skill = ""
    if result == "" then
      skill = table.random(skills)
    end
    local choice = result
    if #choice > 0 then
      skill = choice[1]
    else
      skill = table.random(skills)
    end
    room:handleAddLoseSkills(player, "-" .. skill, nil, true, false)
  end,
  enabled_at_play = Util.FalseFunc,
  enabled_at_response = function(self, player, response)
    return not response and player.dying
  end,
})

sk__guiqu:addEffect("maxcards", {
  name = "#sk__guiqu_maxcards",
  --sk__guiqu,
  fixed_func = function(self, player)
    if player:hasSkill(sk__guiqu.name) then
      return #table.filter(player.player_skills, function(s)
        return s:isPlayerSkill(player) and s.visible
      end)
    end
  end,
})

return sk__guiqu
